ConstantOfShape ================= 将给定内存区间内的所有元素填充为指定的常量值。对于复数类型,实部和虚部需分别传入。 输入: - **output** - 输出数据的起始地址。 - **start** - 填充的起始索引(包含)。 - **end** - 填充的结束索引(不包含)。 - **value** - 需要填充的常量值(针对非复数类型)。 - **value_real** - 复数常量的实部(针对复数类型)。 - **value_imag** - 复数常量的虚部(针对复数类型)。 - **core_mask** - 核掩码(仅适用于共享存储版本)。 输出: - **output** - 填充完成后的数据地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持 int8, int16, int32, fp32, fp64, cplx64, cplx128 - MT7004 支持 fp16, fp32, int16, int32, cplx64 **共享存储版本:** .. c:function:: void i8_constant_of_shape_s(int8_t* output, int start, int end, int8_t value, int core_mask) .. c:function:: void i16_constant_of_shape_s(int16_t* output, int start, int end, int16_t value, int core_mask) .. c:function:: void i32_constant_of_shape_s(int32_t* output, int start, int end, int32_t value, int core_mask) .. c:function:: void fp_constant_of_shape_s(float* output, int start, int end, float value, int core_mask) .. c:function:: void dp_constant_of_shape_s(double* output, int start, int end, double value, int core_mask) .. c:function:: void c64_constant_of_shape_s(float* output, int start, int end, float value_real, float value_imag, int core_mask) .. c:function:: void c128_constant_of_shape_s(double* output, int start, int end, double value_real, double value_imag, int core_mask) **C调用示例(Float32):** .. code-block:: c :linenos: :emphasize-lines: 12 #include int main(int argc, char* argv[]) { // output在DDR空间 float *output = (float *)0xA0000000; int start = 0; int end = 16000; float value = 1.5f; int core_mask = 0xff; // 多核并行填充 fp_constant_of_shape_s(output, start, end, value, core_mask); return 0; } **C调用示例(Complex64):** .. code-block:: c :linenos: :emphasize-lines: 13 #include int main(int argc, char* argv[]) { // output在DDR空间,c64类型通常使用float*指针访问 float *output = (float *)0xA0000000; int start = 0; int end = 1000; // 1000个复数元素 float val_r = 0.5f; float val_i = -0.5f; int core_mask = 0xff; // 注意:c64接口需分别传入实部和虚部 c64_constant_of_shape_s(output, start, end, val_r, val_i, core_mask); return 0; } **私有存储版本:** .. c:function:: void i8_constant_of_shape_p(int8_t* output, int start, int end, int8_t value) .. c:function:: void i16_constant_of_shape_p(int16_t* output, int start, int end, int16_t value) .. c:function:: void i32_constant_of_shape_p(int32_t* output, int start, int end, int32_t value) .. c:function:: void fp_constant_of_shape_p(float* output, int start, int end, float value) .. c:function:: void dp_constant_of_shape_p(double* output, int start, int end, double value) .. c:function:: void c64_constant_of_shape_p(float* output, int start, int end, float value_real, float value_imag) .. c:function:: void c128_constant_of_shape_p(double* output, int start, int end, double value_real, double value_imag) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 10 #include int main(int argc, char* argv[]) { // output在L2空间 float *output = (float *)0x10810000; int start = 0; int end = 1024; float value = 3.14f; fp_constant_of_shape_p(output, start, end, value); return 0; }